HUAWEI_GIT_HOST=http://it-git.huawei.com/StrategicReserve_DEV_GIT/
OUT_GIT_HOST=http://10.60.77.170:8009/gogs/
BASE_DIR=projects.git

#STEP 1 MKDIR BASE DIR
if [ -d $BASE_DIR ]; then
  echo 'projects.git dir exists.'
else
  mkdir $BASE_DIR
fi
cd $BASE_DIR

git config --global credential.helper wincred

# STEP 2 SYNC GIT
for git in 'wefight-p2p-parent' 'wefight-p2p-contract' 'wefight-p2p-domain' 'wefight-p2p-service'
do
  echo Start sync $git .....

    if [ -d $git ]; then
       echo $git already exists
    else
       git clone --mirror -c http.sslVerify=false -c push.default=matching $HUAWEI_GIT_HOST$git.git $git
    fi

    cd $git

    git fetch

    if [ $ERRORLEVEL=0 ]; then
       git push --mirror $OUT_GIT_HOST/$git.git
    else
       echo 'git fetch failed please check shell command.'
    fi

    cd ..

  echo $git 'done'
done
